#include "stm32f10x.h"                  // Device header
void TIMER()
{
	RCC_APB1PeriphClockCmd ( RCC_APB1Periph_TIM2, ENABLE);//设置外部时钟
	
	TIM_InternalClockConfig(TIM2);//设置时基单元的时钟
	
	//配置时基单元
	TIM_TimeBaseInitTypeDef S1;
	S1.TIM_ClockDivision =TIM_CKD_DIV1 ;//指定时钟分频，在这可以随便配
	S1.TIM_CounterMode =TIM_CounterMode_Up ;	//计数模式
	S1.TIM_Period =10000-1;						//自动重装器
	S1.TIM_RepetitionCounter =0;				//高级定时器需要配
	S1.TIM_Prescaler =7200-1;					//预分频
	TIM_TimeBaseInit(TIM2,&S1); 
	
	TIM_ITConfig(TIM2 , TIM_IT_Update, ENABLE);	//使能中断。开启更新中断到NVIC的通路
	
	NVIC_PriorityGroupConfig (NVIC_PriorityGroup_2 );//NVIC优先级分组
	
	//配置NVIC
	NVIC_InitTypeDef S2;
	S2.NVIC_IRQChannel =TIM2_IRQn ;
	S2.NVIC_IRQChannelCmd=ENABLE ; 
	S2.NVIC_IRQChannelPreemptionPriority =2;
	S2.NVIC_IRQChannelSubPriority =1;
	NVIC_Init (&S2);
	
	TIM_Cmd (TIM2,ENABLE );//启动定时器

}